<!DOCTYPE html>

<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>录入考评</title>
    <link rel="stylesheet" href="/vendor/simple-line-icons/css/simple-line-icons.css">
    <link rel="stylesheet" href="/vendor/font-awesome/css/fontawesome-all.min.css">
    <link rel="stylesheet" href="/css/styles.css">
</head>
<body>


        <div class="content">
            <div class="row">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-header bg-light">
                            录入<span th:text="${user.userName}"></span>(工号：<span th:text="${user.userId}"></span>)的绩效值
                        </div>
                        <div class="card-body">
<!-- ********************************************************************************************************** -->
                            <form id="add_form" action="/hr/kpAdd" method="post">
                                <input type="hidden" id="userId" name="userId" th:value="${user.userId}"/>
                                <input type="hidden" id="userName" name="userName" th:value="${user.userName}"/>
                                <div class="mb-4">
                                    <p>加绩效</p>
                                    <div class="row mt-4">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">加绩效原因描述</label>
                                                <input class="form-control" placeholder="请输入原因描述" name="addDesc">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">加绩效时间</label>
                                                <input class="form-control" placeholder="请输入时间(格式：yyyy-MM-dd)" id="addTime" name="addTime">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">加绩效分数</label>
                                                <input class="form-control" placeholder="请输入分数" name="addPoint" id="addPoint">
                                            </div>
                                        </div>
                                    </div>
                                    <button id="kp_add" type="button" class="btn btn-outline-primary">确定</button>
                                    <button type="reset" class="btn btn-outline-danger">重置</button>
                                </div>
                            </form>
<!-- ********************************************************************************************************** -->
                            <hr>
                            <form id="del_form" action="/hr/kpDel" method="post">
                                <input type="hidden" name="userId" th:value="${user.userId}"/>
                                <input type="hidden" name="userName" th:value="${user.userName}"/>
                                <div class="mb-4">
                                    <p>扣绩效</p>
                                    <div class="row mt-4">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">扣绩效原因描述</label>
                                                <input class="form-control" placeholder="请输入原因描述" id="deleteDesc" name="deleteDesc">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">扣绩效时间</label>
                                                <input class="form-control" placeholder="请输入时间(格式：yyyy-MM-dd)" id="deleteTime" name="deleteTime">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">扣绩效分数</label>
                                                <input class="form-control" placeholder="请输入分数" name="deletePoint" id="deletePoint">
                                            </div>
                                        </div>
                                    </div>
                                <!--    <div class="row mt-4">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">选择扣绩效项目</label>
                                                <select class="chooseDepartmentAddPoint" id="chooseDepartmentAddPoint" name="checkId">
                                                    <option th:each="c:${checkList}"
                                                            th:value="${c.checkId}"
                                                            th:text="${c.checkName}"></option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>-->
                                    <button id="kp_del" type="button" class="btn btn-outline-primary">确定</button>
                                    <button type="reset" class="btn btn-outline-danger">重置</button>
                                </div>
                            </form>
<!-- ********************************************************************************************************** -->
                            <hr>
                            <form id="reward_form" action="/hr/kpReward" method="post">
                                <input type="hidden" name="userId" th:value="${user.userId}"/>
                                <input type="hidden" name="userName" th:value="${user.userName}"/>
                                <div class="mb-4">
                                    <p>奖励</p>
                                    <div class="row mt-4">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">奖励级别</label>
                                                <input class="form-control" placeholder="请输入级别" id="rewardReason" name="rewardReson">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">奖励内容</label>
                                                <input class="form-control" placeholder="请输入内容" id="rewardDesc" name="rewardDesc">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">奖励时间</label>
                                                <input class="form-control" placeholder="请输入时间(格式：yyyy-MM-dd)" id="rewardTime" name="rewardTime">
                                            </div>
                                        </div>
                                    </div>
                                    <button id="kp_reward" type="button" class="btn btn-outline-primary">确定</button>
                                    <button type="reset" class="btn btn-outline-danger">重置</button>
                                </div>
                            </form>
<!-- ********************************************************************************************************** -->
                            <!--<hr>
                            <form id="punish_form" action="/hr/kpPunish" method="post">
                                <input type="hidden" name="userId" th:value="${user.userId}"/>
                                <input type="hidden" name="userName" th:value="${user.userName}"/>
                                <div class="mb-4">
                                    <p>惩罚</p>
                                    <div class="row mt-4">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">惩罚原因</label>
                                                <input class="form-control" placeholder="请输入原因" id="punishReason" name="punishReson">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">惩罚内容</label>
                                                <input class="form-control" placeholder="请输入内容" id="punishDesc" name="punishDesc">
                                            </div>
                                        </div>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="form-control-label">惩罚时间</label>
                                                <input class="form-control" placeholder="请输入时间(格式：yyyy-MM-dd)" id="punishTime" name="punishTime">
                                            </div>
                                        </div>
                                    </div>
                                    <button id="kp_punish" type="button" class="btn btn-outline-primary">确定</button>
                                    <button type="reset" class="btn btn-outline-danger">重置</button>
                                </div>
                            </form>-->
<!-- ********************************************************************************************************** -->
                            <hr>
                            <!--<button id="kp_all" type="button" class="btn btn-outline-primary">录入以上全部信息</button>
                            <button id="reset_all" type="button" class="btn btn-outline-primary">重置以上全部信息</button>-->
                        </div>
                    </div>
                </div>
            </div>
        </div>

<script src="/vendor/jquery/jquery.min.js"></script>
<script src="/vendor/popper.js/popper.min.js"></script>
<script src="/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="/vendor/chart.js/chart.min.js"></script>
<script>

    function addSubmit() {
        var input_cart=$("#add_form")
        input_cart.submit();
    }

    function delSubmit() {
        var input_cart = $("#del_form");
        input_cart.submit();
    }

    function reSubmit() {
        var input_cart = $("#reward_form");
        input_cart.submit();

    }

    function puSubmit() {
        var input_cart = $("#punish_form");
        input_cart.submit();
    }

    function checkForm1() {
        var input_cart=document.getElementById("add_form").getElementsByTagName("INPUT");
        for(var i=0; i<input_cart.length; i++) {
            if(input_cart[i].value==""||input_cart[i].value==null) {
                input_cart[i].focus();
                return false;
            }
        }
        return true;
    }

    function checkForm2() {
        var input_cart=document.getElementById("del_form").getElementsByTagName("INPUT");
        for(var i=0; i<input_cart.length; i++) {
            if(input_cart[i].value==""||input_cart[i].value==null) {
                input_cart[i].focus();
                return false;
            }
        }
        return true;
    }

    function checkForm3() {
        var input_cart=document.getElementById("reward_form").getElementsByTagName("INPUT");
        for(var i=0; i<input_cart.length; i++) {
            if(input_cart[i].value==""||input_cart[i].value==null) {
                input_cart[i].focus();
                return false;
            }
        }
        return true;
    }

    function checkForm4() {
        var input_cart=document.getElementById("punish_form").getElementsByTagName("INPUT");
        for(var i=0; i<input_cart.length; i++) {
            if(input_cart[i].value==""||input_cart[i].value==null) {
                input_cart[i].focus();
                return false;
            }
        }
        return true;
    }

/*
    $("#kp_all").click(function () {
        if(!checkForm1()){
            alert("加绩效信息不能为空!");
            return false;
        }else if(!checkForm2()){
            alert("加绩效信息不能为空!");return false;
        }else if(!checkForm3()){
            alert("奖励信息不能为空!");return false;
        }else if(!checkForm4()){
            alert("惩罚信息不能为空!");return false;
        }
        var bagin1 = $('#addTime').val();
        var bagin_r1 = bagin1.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
        if(bagin_r1==null){
            alert("请输入正确的开始时间格式,如:2019-01-01");
            return false;
        }
        var bagin2 = $('#deleteTime').val();
        var bagin_r2 = bagin2.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
        if(bagin_r2==null){
            alert("请输入正确的开始时间格式,如:2019-01-01");
            return false;
        }
        var bagin3 = $('#rewardTime').val();
        var bagin_r3 = bagin3.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
        if(bagin_r3==null){
            alert("请输入正确的开始时间格式,如:2019-01-01");
            return false;
        }
        var bagin4 = $('#punishTime').val();
        var bagin_r4 = bagin4.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
        if(bagin_r4==null){
            alert("请输入正确的开始时间格式,如:2019-01-01");
            return false;
        }
        var number1 = $("#addPoint").val();
        var number2 = $("#deletePoint").val();
        if(!checkRate(number1)){
            alert("加绩效分数请输入正整数");
            return false;
        }else if(!checkRate(number2)){
            alert("加绩效分数请输入正整数");
            return false;
        }
        addSubmit();delSubmit(); reSubmit();puSubmit();
        alert("录入成功！");
    });
*/


    $("#kp_add").click(function () {
        if(!checkForm1()){
            alert("加绩效信息不能为空!");
            return false;
        }
        var bagin = $('#addTime').val();
        var bagin_r = bagin.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
        if(bagin_r==null){
            alert("请输入正确的时间格式,如:2019-01-01");
            return false;
        }
        var number1 = $("#addPoint").val();

        if(!checkRate(number1)){
            alert("加绩效分数请输入正整数");
            return false;
        }
        addSubmit();
        alert("录入加分成功！");
    });

    $("#kp_del").click(function () {
        if(!checkForm2()){
            alert("扣绩效信息不能为空!");return false;
        }
        var number2 = $("#deletePoint").val();
        var bagin = $('#deleteTime').val();
        var bagin_r = bagin.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
        if(bagin_r==null){
            alert("请输入正确的扣绩效时间格式,如:2019-01-01");
            return false;
        }
        if(!checkRate(number2)){
            alert("扣绩效分数请输入正整数");
            return false;
        }
        delSubmit();
        alert("录入加绩效成功！");
    });

    $("#kp_reward").click(function () {
        if(!checkForm3()){
            alert("奖励信息不能为空!");return false;
        }
        var bagin = $('#rewardTime').val();
        var bagin_r = bagin.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
        if(bagin_r==null){
            alert("请输入正确的奖励时间格式,如:2019-01-01");
            return false;
        }
        reSubmit();
        alert("录入奖励成功！");

    });

    $("#kp_punish").click(function () {
        if(!checkForm4()){
            alert("惩罚信息不能为空!");return false;
        }
        var bagin = $('#punishTime').val();
        var bagin_r = bagin.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
        if(bagin_r==null){
            alert("请输入正确的惩罚时间格式,如:2019-01-01");
            return false;
        }
        puSubmit();
        alert("录入惩罚成功！");
    });

    function checkRate(nubmer) {
        var re = /^[1-9]+[0-9]*]*$/; //判断字符串是否为数字 //判断正整数 /^[1-9]+[0-9]*]*$/
        if (!re.test(nubmer)) {
            return false;
        }else{
            return true;
        }
    }
    $("#reset_all").click(function () {
        $('form')[0].reset();$('form')[1].reset();$('form')[2].reset();$('form')[3].reset();
    });
</script>
</body>
</html>
